Ravi Vishwakarma is a dedicated Software Developer with a passion for crafting efficient and innovative solutions. With a keen eye for detail and years of experience, he excels in developing robust software systems that meet client needs. His expertise spans across multiple programming languages and technologies, making him a valuable asset in any software development project.
ICSM Computer
13-Nov-20251. Using
np.concatenate()This is the most common way to join arrays.
Example — Join 1D Arrays
Output:
Example — Join 2D Arrays (Row-wise)
Output:
Example — Join 2D Arrays (Column-wise)
Output:
2. Using
np.stack()Creates a new dimension.
Example:
Output:
Here, arrays are stacked into 2 rows.
3. Using
np.hstack()(Horizontal Stack)Joins arrays side by side.
Output:
For 2D arrays, it stacks column-wise.
4. Using
np.vstack()(Vertical Stack)Joins arrays top to bottom.
Output:
5. Using
np.dstack()(Depth Stack)Stacks arrays into depth (3rd dimension).
Output:
Summary Table
concatenate()stack()hstack()vstack()dstack()